import axios from "axios";
import {useUserStore} from '../stores/user'
const service = axios.create({
    baseURL: "http://localhost:8789",
    timeout: 60000,
    headers: {
    "Access-Control-Allow-Credentials": true
    }, 
    withCredentials: false,
    responseType: "json",
});

service.interceptors.request.use(
    config => {
        if (localStorage.getItem('Authorization')) {
          config.headers.Authorization = localStorage.getItem('Authorization');
        }
        return config;
      },
      error => {
        return Promise.reject(error);
      }
)


service.interceptors.response.use(res => res.data, e=>{
    return Promise.reject(e)
})


export default service;

